﻿<%@ Page Title="Warehouse Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="WarehousePage.aspx.cs" Inherits="MAA.Presentation.PRL.Warehouse.WarehousePage" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <link href="../Styles/Warehouse.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div class="warehouse">
        <h2>
            <asp:Label ID="langWarehouse" runat="server" Text="<%$Resources:language, langWarehouse%>"></asp:Label></h2>
        <br />
        <asp:Label ID="lblWhMess" runat="server" Text="" ForeColor="Red"></asp:Label>
        <br />
        <asp:GridView ID="dgvWarehouse" runat="server" CellPadding="4" BackColor="White"
            BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="2px" AutoGenerateColumns="False"
            OnRowCommand="dgvWarehouse_RowCommand" DataKeyNames="RiceID" 
            onrowdatabound="dgvWarehouse_RowDataBound" >
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:BoundField DataField="RiceID" HeaderText="RiceID" Visible="False" />
                <asp:BoundField DataField="TypeName" HeaderText="Loại gạo">
                    <HeaderStyle HorizontalAlign="Left" />
                    <ItemStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Số lượng hiện tại (kg)">
                    <ItemTemplate>
                        <asp:Label ID="dgvWHlblAmount" runat="server" Text='<%# Bind("Amount") %>' Visible="true"></asp:Label>
                        <asp:TextBox ID="dgvWHtbxAmount" runat="server" Text='<%# Bind("Amount") %>' Visible="false"></asp:TextBox>
                    </ItemTemplate>
                    <ControlStyle Width="100px" />
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:BoundField DataField="CurrentPrice" HeaderText="Giá cập nhật (vnđ)">
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                </asp:BoundField>
                <asp:BoundField DataField="TotalValue" HeaderText="Tổng giá trị (vnđ)">
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                </asp:BoundField>
                <asp:BoundField DataField="MaxPrice" HeaderText="Giá trần (vnd)">
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" ForeColor="#FF0066" />
                </asp:BoundField>
                <asp:BoundField DataField="MinPrice" HeaderText="Gia san (vnd)">
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle ForeColor="#0099CC" HorizontalAlign="Center" />
                </asp:BoundField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:ImageButton ID="dgvWHbtnEdit" runat="server" CommandName="EditAmount" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                            ToolTip="Sửa" ImageUrl="~/WebData/Image/WebImage/Edit.png" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField Visible="False">
                    <ItemTemplate>
                        <asp:ImageButton ID="dgvWHbtnSave" Visible="false" runat="server" CommandName="SaveEdit"
                            CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" ToolTip="Lưu" ImageUrl="~/WebData/Image/WebImage/OK.png" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField Visible="False">
                    <ItemTemplate>
                        <asp:ImageButton ID="dgvWHbtnCancel" Visible="false" runat="server" CommandName="CancelEdit"
                            CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" ToolTip="Hủy"
                            ImageUrl="~/WebData/Image/WebImage/Cancel.png" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:ImageButton ID="dgvWHbtnDelete" runat="server" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                            CommandName="DeleteRice" ToolTip="Xóa" ImageUrl="~/WebData/Image/WebImage/Delete.png"
                            OnClientClick=" return confirm('Bạn có chắc chắn muốn xóa không ?');" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
            <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
            <RowStyle BackColor="White" ForeColor="#330099" Height="40px" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
            <SortedAscendingCellStyle BackColor="#FEFCEB" />
            <SortedAscendingHeaderStyle BackColor="#AF0101" />
            <SortedDescendingCellStyle BackColor="#F6F0C0" />
            <SortedDescendingHeaderStyle BackColor="#7E0000" />
        </asp:GridView>
        <br />
    </div>
    <div class="addCreate">
        <div class="addrice">
            <h2>
                <asp:Label ID="langAddRiceWare" runat="server" Text="<%$Resources:language, langAddRiceWare%>"></asp:Label></h2>
            <br />
            <li>
                <asp:Label class="inFoAddRice" ID="langRiceType" runat="server" Text="<%$Resources:language, langRiceType%>"></asp:Label>
                <asp:DropDownList class="enterAddRice" ID="ddlRiceTypeAdd" runat="server">
                </asp:DropDownList>
            </li>
            <li>
                <asp:Label class="inFoAddRice" ID="langAmount" runat="server" Text="<%$Resources:language, langAmount%>"></asp:Label>
                <asp:TextBox class="enterAddRice" ID="tbxAmountAdd" runat="server" MaxLength="10"></asp:TextBox>kg
                * </li>
            <div class="validate">
                <asp:RequiredFieldValidator class="validate" ID="RequiredFieldValidator1"
                    runat="server" ErrorMessage="Bạn phải nhập số lượng." SetFocusOnError="True"
                    ValidationGroup="Add" ControlToValidate="tbxAmountAdd" Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                <asp:RangeValidator class="validate" ID="RangeValidator4" runat="server"
                    ErrorMessage="Số lượng phải là số nguyên dương." ControlToValidate="tbxAmountAdd"
                    Display="Dynamic" ForeColor="Red" MaximumValue="1000000000" MinimumValue="1"
                    SetFocusOnError="True" Type="Integer" ValidationGroup="Add"></asp:RangeValidator>
            </div>
            <asp:Label class="validate" ID="lblAddError" runat="server" ForeColor="Red"></asp:Label>
            <br />
            <asp:Button class="addCreateButton" ID="btnAdd" runat="server" Text="<%$Resources:language, langAdd%>"
                ValidationGroup="Add" Width="80px" OnClick="btnAdd_Click" />
        </div>
        <div class="createPost">
            <h2>
                <asp:Label ID="langAddPost" runat="server" Text="<%$Resources:language, langAddPost%>"></asp:Label></h2>
            <br />
            <li>
                <asp:Label class="infoCreatePost" ID="lblRiceTypeCreate" runat="server" Text="<%$Resources:language, langRiceType%>"></asp:Label>
                <asp:DropDownList class="infoCreatePost" ID="ddlRiceTypeCreate" runat="server">
                </asp:DropDownList>
            </li>
            <li>
                <asp:Label class="infoCreatePost" ID="langAmount1" runat="server" Text="<%$Resources:language, langAmount%>"></asp:Label>
                <asp:TextBox class="infoCreatePost" ID="tbxAmountCreate" runat="server" MaxLength="10"></asp:TextBox>kg
                *<br />
            </li>
            <div class="validate">
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Bạn phải nhập số lượng."
                    SetFocusOnError="True" ValidationGroup="Create" ControlToValidate="tbxAmountCreate"
                    Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                <asp:RangeValidator ID="RangeValidator3" runat="server" ErrorMessage="Số lượng phải là số nguyên dương."
                    ControlToValidate="tbxAmountCreate" Display="Dynamic" ForeColor="Red" MaximumValue="1000000000"
                    MinimumValue="1" SetFocusOnError="True" Type="Integer" ValidationGroup="Create"></asp:RangeValidator>
            </div>
            <li>
                <asp:Label class="infoCreatePost" ID="langMinAmountOrder" runat="server" Text="<%$Resources:language, langMinAmountOrder%> "></asp:Label>
                <asp:TextBox class="infoCreatePost" ID="tbxMinCreate" runat="server" MaxLength="10"></asp:TextBox>kg
            </li>
            <div class="validate">
                <asp:CompareValidator ID="CompareValidator4" runat="server" ErrorMessage="Số lượng mua nhỏ nhất phải nhỏ hơn số lượng bán."
                    ControlToValidate="tbxMinCreate" SetFocusOnError="True" Type="Integer" ValidationGroup="Create"
                    ValueToCompare="0" Display="Dynamic" ForeColor="Red" Operator="LessThanEqual"
                    ControlToCompare="tbxAmountCreate"></asp:CompareValidator>
                    <br/>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Số lượng mua nhỏ nhất phải lớn hơn 0."
                    ControlToValidate="tbxMinCreate" SetFocusOnError="True" Type="Integer" ValidationGroup="Create"
                    ValueToCompare="1" Display="Dynamic" ForeColor="Red" Operator="GreaterThanEqual"></asp:CompareValidator>
            </div>
            <li>
                <asp:Label class="infoCreatePost" ID="langUnitPrice" runat="server" Text="<%$Resources:language, langUnitPrice%>"></asp:Label>
                <asp:TextBox class="infoCreatePost" ID="tbxPriceCreate" runat="server" MaxLength="10"></asp:TextBox>vnđ
                * </li>
            <div class="validate">
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="<%$Resources:language, langEnterPriceBuy%>"
                    SetFocusOnError="True" ValidationGroup="Create" ControlToValidate="tbxPriceCreate"
                    Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                <asp:RangeValidator ID="RangeValidator2" runat="server" ErrorMessage="Giá bán phải là số nguyên dương."
                    ControlToValidate="tbxPriceCreate" Display="Dynamic" ForeColor="Red" MaximumValue="1000000000"
                    MinimumValue="1" SetFocusOnError="True" Type="Integer" ValidationGroup="Create"></asp:RangeValidator>
            </div>
            <li>
                <asp:Label class="infoCreatePost" ID="langDifferencePrice" runat="server" Text="<%$Resources:language, langDifferencePrice%>"></asp:Label>
                <asp:TextBox class="infoCreatePost" ID="tbxPercentCreate" runat="server" MaxLength="2"
                    Text="0"></asp:TextBox>% </li>
            <div class="validate">
                <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Tỉ lệ chênh lệch từ 0 đến 100%"
                    ControlToValidate="tbxPercentCreate" Display="Dynamic" ForeColor="Red" MaximumValue="100"
                    MinimumValue="0" SetFocusOnError="True" Type="Integer" ValidationGroup="Create"></asp:RangeValidator>
            </div>
            <li>
                <asp:Label class="infoCreatePost" ID="langAddressBuy" runat="server" Text="<%$Resources:language, langAddressBuy%>"></asp:Label>
                <asp:TextBox class="infoCreatePost" ID="tbxAddressCreate" runat="server" TextMode="MultiLine"
                    MaxLength="255" Font-Names="Segoe UI" Style="resize: none;" onkeypress="return CheckLength();"></asp:TextBox>
            </li>
            <li>
                <asp:Label class="infoCreatePost" ID="langProvince" runat="server" Text="<%$Resources:language, langProvince%>"></asp:Label>
                <asp:DropDownList class="infoCreatePost" ID="ddlProvinceCreate" runat="server">
                </asp:DropDownList>
            </li>
            <br/>
            <asp:Label class="validate" ID="lblCreateError" runat="server" ForeColor="Red"></asp:Label>
            <br/>
            <asp:Button class="addCreateButton" ID="btnCreate" runat="server" Text="<%$Resources:language, langCreate%>"
                ValidationGroup="Create" OnClick="btnCreate_Click" Width="80" />
        </div>
    </div>
    <script type="text/javascript">
        function CheckLength() {
            var textbox = document.getElementById("<%=tbxAddressCreate.ClientID%>").value;
            if (textbox.trim().length >= 255) {
                return false;
            }
            else {
                return true;
            }
        }
                    </script>
</asp:Content>
